package dao.impl;

import com.google.common.collect.ImmutableMap;
import dao.FavoriteDao;
import domain.Favorite;
import org.springframework.stereotype.Repository;

import java.util.Map;

/**
 * Created by zf on 2015/7/17.
 */

@Repository
public class FavoriteDaoImpl extends BaseGenericDao<Favorite, Long> implements FavoriteDao {


    @Override
    public Favorite queryByUserIdAndFavorUserId(long userId, long favorUserId) {

        Map<String, Object> params = ImmutableMap.<String, Object>builder()
                .put("userId", userId)
                .put("favorUserId", favorUserId).build();

        return queryOne("select", params);
    }

    @Override
    public void updateOvonic(long favoriteId, char ovonic) {
        Map<String, Object> params = ImmutableMap.<String, Object>builder()
                .put("id", favoriteId)
                .put("ovonic", ovonic).build();

        update("update-ovonic", params);
    }
}
